home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 451-475 / disk_463 / ilbm / aboutiff < prev    next >
Text File  |  1992-05-06  |  10KB  |  224 lines

  1.     Electronic Arts is a company that deserves credit for helping make life
  2. easier for the Amiga programmer and end user. The company has promoted the
  3. Amiga since the computer's introduction more so than CBM (although very few
  4. organizations have promoted the Amiga less than its manufacturer). By esta-
  5. blishing IFF standards on behalf of CBM and releasing source code for reading
  6. and writing IFF files, Electronic Arts has helped make the Amiga the success
  7. that it is in the video/graphics market. Unfortunately, the people who wrote
  8. the documents describing the IFF file formats have an appalling lack of respect
  9. for the English language. No effort was made to be concise and clear. Sentences
  10. seem to have been constructed by heaving several, long phrases together, and
  11. subsequently inserting a verb or two. Then, if the text didn't sound
  12. "technical" or "serious" enough, adjectives were invented, and brazenly thrust
  13. into any sentence of less than 40 words. This mish-mash of technical newspeak
  14. is typical of computer programmers who never learned to write in any language
  15. other than Pascal. In fact, if the trend toward inventing technical jargon
  16. continues, we may see the day when technical literature will have the words
  17. BEGIN and END surrounding each "standard written language module" (i.e.
  18. paragraph).  Many misguided programmers (and others engaged in scientific
  19. disciplines) are also taught that any use of the first person (i.e. I or we)
  20. is too conversational, and therefore unprofessional. Apparently, the function
  21. of technical literature is not to converse, but to bore. Because the original
  22. IFF documents exhibit all of these flaws, I will attempt to paraphrase those
  23. documents. I do not guarantee that I will have correctly ascertained the
  24. intentions of the lifeform that wrote those documents, so you should consult
  25. the original text.
  26.  
  27.   BEGIN
  28.   IFF stands for "InterChange Format Files". This is some of that technical
  29. jargon that I was alluding to earlier. Basically, an IFF file is a set of
  30. data that is in a form that many, unrelated programs can read. An IFF file
  31. should not have anything in it that was intended specifically for just one,
  32. particular program. If a program must save some "personal" data in an IFF
  33. file, it must be saved in a manner which allows another program to "skip
  34. over" this data. There are several different types of IFF files. ILBM files
  35. store picture data. SMUS files store musical scores. 8SVX store sampled
  36. sounds. Each of these files must start with an ID which indicates that it is
  37. indeed an IFF file, followed by an ID that indicates which type of file. So
  38. what is an ID? An ID is four, printable ascii characters. If you use the CLI
  39. Type command (opt h) to print out an IFF file to the CLI window, you will
  40. notice that every so often you will see 4 letters in a row. These 4 letters
  41. are an ID. Every IFF file must start with one of the following 3 IDs.
  42.  
  43.   'FORM'  'LIST'  'CAT '
  44.  
  45.  If the first 4 chars (bytes) in a file are not one of these, then it is not
  46. an IFF file. These IDs are referred to as group IDs in EA literature.
  47.     END
  48.  
  49.   After this group ID, there is a ULONG that indicates how many bytes are
  50. in the entire file. This count does not include the 4 byte group ID, nor this
  51. LONG. This LONG is useful if you wish to load the rest of the file into mem-
  52. ory to examine it. After this LONG, there is an ID that indicates which type
  53. of IFF file this is. As mentioned earlier, "ILBM", "SMUS", and "8SVX" are 3
  54. types of IFF files. There are many more, and programmers are always inventing
  55. new types for lack of better things to do. What you find after the type ID
  56. depends on which type it is (i.e. From here on, an ILBM will be different
  57. than an 8SVX). Here is the beginning of a typical ILBM file.
  58.  
  59.   'FORM'  <- OK. This really is an IFF file.
  60.   13000     <- There are 13000 more bytes after this ULONG
  61.   'ILBM'  <- It is an ILBM (picture) file
  62.  
  63.   One thing that all IFF files do have in common after the group ID, byte
  64. count, and type ID, is that data is organized into chunks. OK, more jargon.
  65. What's a chunk? A chunk consists of an ID, a ULONG that tells how many bytes
  66. of data are in the chunk, and then all those data bytes. For example, here
  67. is a CMAP chunk (which would be found in an ILBM file).
  68.  
  69.   'CMAP'          <- This is the 4 byte chunk ID
  70.   6              <- This tells how many data bytes are in the chunk (chunkSize)
  71.   0,0,0,1,1,4 <- Here are the 6 data bytes
  72.  
  73.   Notice that the chunk size doesn't include the 4 byte ID or the ULONG for
  74. the chunk Size.
  75.   So, all IFF files are made up of several chunks. There are a few other
  76. details to note. A chunk cannot have an odd number of data bytes (such as 3).
  77. If necessary, an extra zero byte must be written to make an even number of
  78. data bytes. The chunk Size doesn't include this extra byte. So for example,
  79. if you want to write 3 bytes in a CMAP chunk, it would look like this:
  80.  
  81.   'CMAP'
  82.   3          <- Note that chunk Size is 3
  83.   0,1,33,0 <- Note that there is an extra zero byte
  84.  
  85.   In the preceding example, the group ID was 'FORM'. There are other group
  86. IDs as well. A 'CAT ' is a collection of many different FORMs all stuck
  87. together consecutively in 1 IFF file. For example, if you had an animation
  88. with 6 sound effects, you would want to save the animation frames in an ANIM
  89. FORM, and you would want to save the sound effects in several 8SVX FORMs
  90. (one per sound effect). Note: a better way to store sound samples would be
  91. the SAMP format. See Fish Disc #203. You could save the animation and sound
  92. in 7 separate files. The ANIM file would start this way:
  93.  
  94.   FORM
  95.   120000  <- Whatever the size happens to be (this is expressed in 32 bits)
  96.   ANIM
  97.  
  98.   Each 8SVX file would start this way:
  99.  
  100.   FORM
  101.   8000 <- whatever size
  102.   8SVX
  103.  
  104.   If the user wanted to copy the data to another disc, he would have to copy
  105. 7 files. On the other hand, you could save all the data in one CAT file.
  106.  
  107.   CAT
  108.   4+120008+8008+2028+...  <- The total size of the ANIM and the 6 8SVX files
  109.   '     '                 <- Type of CAT. 4 spaces for the type ID means "a grab bag"
  110.                              of IFF FORMs are going to be inside of this CAT
  111.   FORM
  112.   120000
  113.   ANIM
  114.   ...all the chunks in the ANIM file placed here (note: ANIMs have imbedded
  115.       ILBM FORMs)
  116.  
  117.   FORM
  118.   8000
  119.   8SVX
  120.   ...all the chunks in the first sound effect here
  121.  
  122.   FORM
  123.   2020
  124.   8SVX
  125.   ...all the chunks in the second sound effect here
  126.  
  127.   ...etc. for the other 4 sound effects
  128.  
  129.   To further complicate matters, there are LISTs. LISTs are a lot like CATs
  130. except that there is an additional group ID associated with LISTs. That ID
  131. is a PROP. LISTs can have imbedded PROPS just like an ILBM can have an im-
  132. bedded CMAP chunk. A PROP header looks very much like a FORM header in that
  133. you must follow it with a type ID. For example, here is an ILBM PROP with
  134. a CMAP in it.
  135.  
  136.   PROP  <- Here's a PROP
  137.   4+14  <- Here's how many bytes follow in the PROP
  138.   ILBM  <- It's an ILBM PROP
  139.   CMAP        <- Here's a CMAP chunk inside this ILBM PROP
  140.   6            <- There are 6 bytes following in this CMAP chunk
  141.   0,0,0,1,1,4 
  142.  
  143.      LISTs are meant to encompass similiar FORMs (i.e. several 8SVX
  144. files stuck together). Often, when you have similiar FORMs stuck together,
  145. some of the chunks in the individual FORMs are the same. For example,
  146. assume that we have 2 8SVX sound effects. 8SVX FORMs can have a NAME chunk
  147. which contains the ascii string that is the name of the sound effect. Also
  148. assume that both sounds are called "car crash". Wouldn't it be nice if we
  149. didn't have to have the same NAME chunk in each 8SVX FORM like so:
  150.  
  151.   CAT                    <- We put the 2 files into 1 CAT
  152.   4+1004+504
  153.   8SVX                <- It's an CAT of several 8SVX FORMs
  154.  
  155.   FORM                <- here's the start of the first sound effect file
  156.   1000
  157.   8SVX 
  158.  
  159.   ...some chunks
  160.  
  161.   NAME                <- here's the name chunk for the 1st sound effect
  162.   9
  163.   'car crash',0
  164.  
  165.   ...more chunks
  166.  
  167.   FORM                <- here's the start of the second sound effect file
  168.   500
  169.   8SVX
  170.  
  171.   ...some chunks
  172.  
  173.   NAME                <- here's the name chunk for the 2nd sound effect. Look
  174.   9                        familiar?
  175.   'car crash',0
  176.  
  177.   ...more chunks
  178.  
  179.   With a LIST, we can have PROPs. A PROP is group ID that allows us to place
  180. chunks that pertain to all the FORMs in the LIST. So, we can rip out the
  181. NAME chunks inside both 8SVX FORMs and replace it with one NAME chunk inside
  182. of a PROP.
  183.  
  184.   LIST                <- Notice that we use a LIST instead of a CAT
  185.   4+30+990+490+...
  186.   8SVX
  187.  
  188.   PROP                <- Here's where we put chunks intended for ALL the
  189.   22                        subsequent FORMS; inside a PROP.
  190.   8SVX                <- type of PROP
  191.   NAME                <- here's the name chunk inside of the PROP
  192.   9
  193.   'car crash',0
  194.  
  195.  
  196.   FORM                <- here's the start of the first sound effect file
  197.   982                    <- size is 18 bytes less because no NAME chunk here
  198.   8SVX 
  199.  
  200.   ...some chunks, but no NAME chunk
  201.  
  202.   FORM                <- here's the start of the second sound effect file
  203.   482
  204.   8SVX 
  205.  
  206.   ...some chunks, but no NAME for this guy either
  207.  
  208.   Notice that the PROP group ID is followed by a type ID (in this case 8SVX).
  209. This means that the PROP only affects any 8SVX FORMs. If you were to sneak
  210. in an SMUS FORM at the end, the NAME chunk would not apply to it. Also, if
  211. you included a NAME chunk in one of the 8SVX FORMs, it would override the
  212. PROP. For example, assume that you have a LIST containing 10 8SVX FORMs. All
  213. but 1 of them is named "CBM needs an advertising budget". You can store a
  214. NAME chunk in a PROP 8SVX for "CBM needs an advertising budget". Then, in
  215. the one 8SVX FORM whose name is not "CBM needs an advertising budget", you
  216. can include a NAME chunk to override the PROP.
  217.   It should be noted that you can take several LISTs and squash them toge-
  218. ther inside of a CAT or another LIST.² Personally, I have never seen a data
  219. file with this level of nesting, and doubt that it would be of much use. If
  220. you need this level of complexity, forget IFF and make your own proprietary
  221. data format, then give info to anyone who wants to access your data. No doubt,
  222. somewhere, there is a moron devising a plot to inflict a CAT of LISTs upon an
  223. unsuspecting public now that VirusX has defeated his more devious aspirations.
  224.